﻿using CSharpLibs.Annotations;

using System.Collections;
using System.Collections.Generic;

namespace System
{
	[Builtin]
	public class CharEnumerator : Object, IEnumerator<char>, IEnumerator, IDisposable
	{
		// Fields
		private char currentElement;
		private int index;
		private string str;

		// Methods
		internal CharEnumerator(string str)
		{
			this.str = str;
			this.index = -1;
		}

		public void Dispose()
		{ this.str = null; }

		public bool MoveNext()
		{
			if(this.index < (this.str.Length - 1))
			{
				this.index++;
				this.currentElement = this.str[this.index];
				return true;
			}

			this.index = this.str.Length;
			return false;
		}

		public void Reset()
		{
			this.currentElement = '\0';
			this.index = -1;
		}

		public char Current
		{ get { return this.currentElement; } }

		object IEnumerator.Current
		{ get { return this.currentElement; } }
	}
}